#include "thread.h"

thread_t* running_thread;
GList threads_list;

/**
 * Function that returns the current running thread
 * @return a pointer to the current running thread or NULL
 **/
thread_t thread_self(void) {
  return running_thread;
}

/**
 * Function that adds a thread to the threads FIFO list, links the desired
 * function to that thread, runs that thread
 * @return 0 if success, -1 if fail
 * @param 
 **/
int thread_create(void *(*func)(void *), void *funcarg) {

  

}

/**
 * Passer la main à un autre thread.
 * @return 0 if success, -1 if fail
 * @param
 */
extern int thread_yield(void) {
  thread_t tmp;
  swapcontext(tmp->context ,g_list_next(threads_list)->context);
  running_thread = g_list_next(threads_list);
  g_list_last(&threads_list)->next = &tmp;
  return 0;
}
